#include <iostream>
using namespace std;

int main(int argc,const char *argv[])
{
    //bool ok;
    //ok = true;
    //cout << "ture = " << ok << endl;
    //ok = false;
    //cout << "false = " << ok << endl;
    //cout << sizeof(bool) << endl;
    string str = "hello world";
    cout << str << endl;

    //string的使用的API接口
    cout << str[0] << endl;
    //cout << str[100] << endl;

    //at有边界检查的：
    cout << str.at(0) << endl;
    //cout << str.at(100) << endl;

    //获取string中保存的字符串的首地址
    const char * s = str.data();
    const char * s1 = str.c_str();
    cout << s << endl;
    cout << s1 << endl;
    str.push_back('P');
    str.pop_back();
    cout << str << endl;
    //+=后符字符串到原字符串。改变原字符串。
    str+="BigWorld";
    cout << str << endl;

    string str1 = "hello";
    string str2 = "world";
    //拼接字符串，不改变原字符串的首地址
    cout << str1 + str2 << endl;
    return 0;
}